﻿using System;
using System.Text.RegularExpressions;



namespace ExamUtils
{
    /// <summary>
    /// 校验类
    /// </summary>
    public class CheckUtils
    {
        /// <summary>
        /// 校验学号
        /// </summary>
        /// <param name="stuNo"></param>
        /// <returns></returns>
        public static bool CheckStudentNo(string stuNo)
        {
            bool isMatch = false;
            try
            {
                isMatch = Regex.IsMatch(stuNo, ConstMember.studentNoRegexStr, RegexOptions.Multiline);
            }
            catch (ArgumentException ex)
            {
                //TODO 异常写日志文件, 后续开发 
            }
            return isMatch;
        }

        /// <summary>
        /// 校验ipv4地址
        /// </summary>
        /// <param name="ipAdd"></param>
        /// <returns></returns>
        public static bool CheckIPAddress(string ipAdd)
        {
            bool isMatch = false;
            try
            {
                isMatch = Regex.IsMatch(ipAdd, ConstMember.ipAddressRegexStr, RegexOptions.Multiline);
            }
            catch (ArgumentException ex)
            {
                //TODO 异常写日志文件, 后续开发 
            }
            return isMatch;
        }

        /// <summary>
        /// 检验端口号
        /// </summary>
        /// <param name="port"></param>
        /// <returns></returns>
        public static bool CheckPort(int port)
        {
            return 0 < port && port < 65535;
        }


    }
}
